/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ru.prjpeople.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Vladimir
 */
public class CheckAuthenticationServlet extends HttpServlet {
    
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        String login = request.getParameter("login");
        String password = request.getParameter("password");
        if(login != null && password != null
           && login.equals("admin") && login.equals("admin")) {
            request.getSession().setAttribute("user", true);
            response.sendRedirect("");
        }
        else {
            request.setAttribute("error", "такого юзера нет в системе");
            request.getRequestDispatcher("/login.jsp").forward(request, response);
        }
    } 
}
